package andev.aandroidlib.activity;

import android.os.Bundle;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

import java.net.CookieHandler;
import java.net.CookieManager;

/**
 * Created by lzy1g on 2015/8/14.
 */
public class ANetActivity extends AActivity {
    private static RequestQueue appRequestQueue;
    private RequestQueue activityRequestQueue;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CookieManager cookieManager = new CookieManager();
        CookieHandler.setDefault(cookieManager);
    }

    /**
     * 2015年7月24日上午8:48:25
     *
     * @return 获得Volley的在整个应用的RequetQueue队列
     * TODO
     */
    public RequestQueue getAppRequestQueue() {
        if (appRequestQueue == null) {
            appRequestQueue = Volley.newRequestQueue(getApplicationContext());
        }
        return appRequestQueue;
    }

    /**
     * 2015年7月24日上午8:50:46
     *
     * @return 获得一个Activity的RequestQueue
     * TODO
     */
    public RequestQueue getActivityRequestQueue() {
        if (activityRequestQueue == null) {
            activityRequestQueue = Volley.newRequestQueue(this);
        }
        return activityRequestQueue;
    }
}
